﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Portal.Cms.Model;
using System.Data;
using System.Collections.ObjectModel;
using DtSearchIndexService;
using Portal.Core;
using Portal.Web.Utility;

namespace Portal.Cms.Bussiness.Template
{
    public interface ICmsProcess
    {
        string ServiceId { get; }
        string ConnectionString(string SiteId);

        void ChangePassword(
            string SiteId,
            string AssetCode,
            string LoginName,
            string OldPassword,
            string NewPassword,
            string ReNewPassword);
        DataTypeCls CreateDataTypeModel(string SiteId, string DataTypeId);
        CmsDataCls CreateCmsDataModel(IDbTransaction Trans, string SiteId, string CmsDataId);
        DataSaveHistoryCls CreateCmsDataHistoryModel(IDbTransaction Trans, string SiteId, string CmsDataId, string HistoryDataId);
        CmsDataCls CreateCmsDataModel(IDbTransaction Trans, string SiteId, string CmsDataId, bool IncPreview, bool IncDownload);
        CmsDataCls CreateCmsDataModel(IDbTransaction Trans, string SiteId, string CmsDataId, bool IncPreview, bool IncDownload, string ConnectionString);

        GroupDataCls CreateGroupDataModel(IDbTransaction Trans, string SiteId, string GroupDataId);
        DataTypeCls[] ReadingDataType(string SiteId);
        DataTypeCls[] ReadingDataTypeForRelation(string SiteId);
        GroupDataCls[] ReadingGroupData(string SiteId, string DataTypeId);
        GroupDataCls[] ReadingGroupDataForPermission(string SiteId);
        GroupDataCls[] ReadingGroupData(string SiteId, string DataTypeId, string AssetCode);
        void AddGroupData(string SiteId, string DataTypeId, string Alias, string LinkDataAlias, string Subject, string Description);
        void SaveGroupData(string SiteId, string DataTypeId, string GroupDataId, string Alias, string LinkDataAlias, string Subject, string Description);
        void DeleteGroupData(string SiteId, string GroupDataId);
        void SaveXml(
            IDbTransaction Trans,
            string SiteId,
            string AssetCode,
            string GroupDataId,
            DateTime EntryDate,
            string DataId);

        string AddCmsData(
                IDbTransaction Trans,
                string SiteId,
                string WorkflowDefId,
                string DataLanguage,
                string DataId,
                CmsDataCls OCmsData,
                bool blnSaveXml);

        string AddCmsData(
                IDbTransaction Trans,
                string SiteId,
                string WorkflowDefId,
                string DataLanguage,
                string DataId,
                CmsDataCls OCmsData,
                CmsVoteAnswerItemCls[] CmsVoteAnswerItems,
                bool blnSaveXml);
        
                //string GroupDataId,
                //string ParentDataId,
                //string Alias,
                //string Subject,
                //string OtherSubject,
                //string Description,
                //string Body,
                //string Source,
                //string Url,
                //string Target,
                //string UploadFile,
                //string SortIndex,
                //string DocType,
                //string DocField,
                //string DocReleaseFrom,
                //string DocSigner,
                //string DocStatus,
                //DateTime SignDate,
                //DateTime ReleaseDate,
                //DateTime EffectedDate,
                //DateTime EndEffectedDate,
                //string ReplaceDoc,
                //string ModifyDoc,
                //string VoteType,
                //bool blnSaveXml,
                //int IsNew,
                //int AttachedSearchable,
                //string GroupDataFolderId,
                //string SubDataType,

                //string Categories,
                //string CategoryIds,
                //string HotCategoryIds,
                //string NewsTypeId,
                //string ImageLevelId,
                //string EventId,
                //string ExpImageCount,
                //string ExpImageLevelId,
                //string NewsLevelId,
                //int IsFocus,
                //int IsShowAuthor,
                //int IsAdv,
                //string Keyword,
                //string SurveyCode,
                //string Note,
                //DateTime ExpiredDate


        void SaveCmsData(
                IDbTransaction Trans,
                string SiteId,
                string DataId,
                CmsDataCls OCmsData,
                bool blnSaveXml
            );

        void SaveCmsData(
               IDbTransaction Trans,
               string SiteId,
               string DataId,
               CmsDataCls OCmsData,
               CmsVoteAnswerItemCls[] CmsVoteAnswerItems,
               bool blnSaveXml
           );

        void DeleteCmsData(string SiteId, string DataId);
        void ChangeAvatarFile(string SiteId, string DataId, string AvatarFile);
        void ChangeAttachDocFile(string SiteId, string DataId, string AttachDocFile);
        void PublicData(IDbTransaction Trans, string SiteId, string DataId);
        void UnPublicData(IDbTransaction Trans, string SiteId, string DataId);
        void PublicGroupData(string SiteId, string GroupDataId);
        void UnPublicGroupData(string SiteId, string GroupDataId);
        CmsDataCls[] ReadingCmsData(string SiteId, string GroupDataId, string ParentDataId);
        CmsDataCls[] ReadingCmsDataForDataType(string SiteId, string DataType);
        CmsDataCls[] ReadingCmsDataForVote(string SiteId, string GroupDataId, string ParentDataId);
        CmsDataCls[] ReadingCmsDataForVoteDetail(
            string SiteId,
            string GroupDataId,
            string ParentDataId,
            string UserId);
        CmsDataCls[] ReadingCmsDataIsPublic(string SiteId, string GroupDataId, string ParentDataId);
        CmsDataCls[] ReadingTopCmsDataIsPublicSortByDate(string SiteId, string GroupDataId, string ParentDataId, string SortType, int Top);
        CmsDataCls[] ReadingCmsDataIsPublicSortByDate(string SiteId, string GroupDataId, string ParentDataId, string SortType);
        CmsDataCls[] ReadingCmsDataIsPublicExclusive(string SiteId, string GroupDataId, string ExclusideId, int TOP);
        GroupDataCls[] ReadingGroupDataForInput(string SiteId, string DataType);
        GroupDataCls[] ReadingGroupDataForInput(string SiteId);
        CmsDataCls[] SearchCmsData(string SiteId, string DataTypeId, string Subject, string Description);
        CmsDataCls[] SearchCmsData(string SiteId, string DataTypeId, string Keyword);
        void SendContactUs(
            string SiteId,
            string FromName,
            string FromEmail,
            string FromAddress,
            string FromPhone,
            string FromTitle,
            string SendContent);
        GroupDataCls[] ReadingGroupDataForVote(string SiteId, string DataTypeId, string AssetCode, string StudentId);
        GroupDataCls[] ReadingGroupDataForSurvey(string SiteId, string AssetCode);
        void AddDocumentRelation(string SiteId, string SrcDataId, string RelDataId, string RelationTypeId);
        void AddDocumentRelationList(string SiteId, string SrcDataId, string[] RelDataId);
        void DeleteDocumentRelation(string SiteId, string RelationDataId);
        void DeleteDocument(string SiteId, string DataId);
        CmsDataRelationCls[] ReadingDocumentRelation(string SiteId, string SrcDataId, string RelationTypeId);
        CmsDataRelationCls[] ReadingDocumentRelationOut(string SiteId, string SrcDataId, string RelationTypeId);
        Collection<CmsDataCls> GetDocumentRelation(string SiteId, string DataId, Collection<CmsDataCls> ResCmsData);
        Collection<CmsDataCls> GetDocumentRelationRevert(string SiteId, string DataId, Collection<CmsDataCls> ResCmsData);
        void SendForPublish(string SiteId, string DocumentId);
        CmsDataCls[] ReadingCmsDataForPublish(string SiteId, string GroupDataId);


        void SyncGroupDataCategory(string SiteId, Collection<GroupDataCategoryCls> GroupDataCategories);
        GroupDataCategoryCls[] ReadingGroupDataCategory(string SiteId, string DataLanguageId);
        GroupDataCategoryCls[] ReadingGroupDataCategoryForWorkflowAction(
            string SiteId, string DataLanguageId, string RoleId, string UserId);


        DataSaveHistoryCls[] ReadingDataSaveHistory(string SiteId, string CmsDataId);
        void ExecuteIndexService(string SiteId);
        DataSaveHistoryCls[] ReadingDataSaveHistoryDetail(string SiteId, string DataSaveHistoryId, string CmsDataId);
        
        StudentSurveyCls[] ReadingVotedStudentList(string SiteId, string GroupDataId);
        StudentSurveyCls CreateStudentSurveyModel(string SiteId, string StudentSurveyId);

        GroupDataFolderCls CreateGroupDataFolderModel(IDbTransaction Trans, string SiteId, string GroupDataFolderId);
        GroupDataFolderCls[] ReadingGroupDataFolder(IDbTransaction Trans, string SiteId, string GroupDataId, string ParentGroupDataFolderId);
        string AddGroupDataFolder(IDbTransaction Trans, string SiteId,string GroupDataId, string ParentGroupDataFolderId, string FolderName,int SortIndex);
        
        void MoveGroupDataFolder(IDbTransaction Trans, string SiteId, string GroupDataId, string MoveGroupDataFolderId, string ToGroupDataFolderId);
        void MoveDocumentToGroupDataFolder(IDbTransaction Trans, string SiteId, string GroupDataId, string MoveDocumentId, string ToGroupDataFolderId);

        string SaveGroupDataFolder(IDbTransaction Trans, string SiteId, string GroupDataId, string GroupDataFolderId, string FolderName, int SortIndex);
        void DeleteGroupDataFolder(IDbTransaction Trans, string SiteId, string GroupDataId, string GroupDataFolderId);

        CmsDataCls ReadingCmsDataForVoteDetailText(
            string SiteId,
            string GroupDataId,
            string ParentDataId,
            string StudentSurveyId);
    }
}
